package com.pine.manager.pineframework.trigger;

import com.pine.common.beans.pineframework.request.SysMenuSaveOrUpdateRequest;
import com.pine.common.beans.request.BatchIdRequest;
import com.pine.common.beans.response.DeleteResponse;
import com.pine.common.trigger.TriggerContext;
import com.pine.common.trigger.TriggerUtil;
import com.pine.manager.core.TriggerTypeEnum;

/**
 * <p>
 * 菜单 触发器管理类
 * </p>
 *
 * @author pine manage
 * @since 2024-08-13
 */
public class SysMenuTriggerManager {

    /**
     * 保存或更新菜单
     *
     * @param request 请求体
     * @return 响应体
     */
    public static Boolean saveOrUpdate(SysMenuSaveOrUpdateRequest request) {
        TriggerContext<SysMenuSaveOrUpdateRequest> triggerContext = new TriggerContext<>(TriggerTypeEnum.SYS_MENU_SAVE_OR_UPDATE, request);
        return TriggerUtil.triggerWithLock(triggerContext);
    }

    /**
     * 删除
     *
     * @param request 请求体
     * @return 响应体
     */
    public static DeleteResponse delete(BatchIdRequest<Long> request) {
        TriggerContext<BatchIdRequest<Long>> triggerContext = new TriggerContext<>(TriggerTypeEnum.SYS_MENU_DELETE, request);
        return TriggerUtil.triggerWithLock(triggerContext);
    }
}
